package yunhe.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import yunhe.biz.IProcureBiz;
import yunhe.biz.impl.CusBizImpl;
import yunhe.biz.impl.ProcureBizImpl;
import yunhe.biz.impl.StorageBizImpl;
import yunhe.biz.impl.SupBizImpl;
import yunhe.entity.Customer;
import yunhe.entity.EmpMsg;
import yunhe.entity.Product;
import yunhe.entity.Storage;
import yunhe.entity.Supplier;
@WebServlet(name="AddSupplierServlet",urlPatterns="/AddSupplierServlet")
public class AddSupplierServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		String supId=request.getParameter("supId");
		String supName=request.getParameter("supName");
		String supLinkMan=request.getParameter("supLinkMan");
		String supTel=request.getParameter("supTel");
		String supAddr=request.getParameter("supAddr");
		String supEmail=request.getParameter("supEmail");
		String supBank=request.getParameter("supBank");
		String supAccount=request.getParameter("supAccount");
		String supTaxNum=request.getParameter("supTaxNum");
		Supplier supplier=new Supplier(supId, supName, supLinkMan, supTel, supAddr, supEmail, supBank, supAccount, supTaxNum);
		PrintWriter out=response.getWriter();
		SupBizImpl biz=new SupBizImpl();
		if(biz.addSupplier(supplier)){
			out.print("<script>alert('添加供应商成功');location.href='/purchase/addProduct.jsp'</script>");
		}else{
			out.print("<script>alert('添加供应商失败');location.href='/purchase/addProduct.jsp'</script>");
		}
	}
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
